home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / os2 / adaptor.zip / ADAPT.ZIP / adaptor / src / shapes.c < prev    next >
Text File  |  1994-01-03  |  20KB  |  984 lines

  1. # include "Shapes.h"
  2. # include "yyShapes.w"
  3. # include <stdio.h>
  4. # if defined __STDC__ | defined __cplusplus
  5. #  include <stdlib.h>
  6. # else
  7.    extern void exit ();
  8. # endif
  9. # include "Tree.h"
  10. # include "Definiti.h"
  11.  
  12. # ifndef NULL
  13. # define NULL 0L
  14. # endif
  15. # ifndef false
  16. # define false 0
  17. # endif
  18. # ifndef true
  19. # define true 1
  20. # endif
  21.  
  22. # ifdef yyInline
  23. # define yyALLOC(tree, free, max, alloc, nodesize, make, ptr, kind) \
  24.   if ((ptr = (tree) free) >= (tree) max) ptr = alloc (); \
  25.   free += nodesize [kind]; \
  26.   ptr->yyHead.yyMark = 0; \
  27.   ptr->Kind = kind;
  28. # else
  29. # define yyALLOC(tree, free, max, alloc, nodesize, make, ptr, kind) ptr = make (kind);
  30. # endif
  31.  
  32. # define yyWrite(s) (void) fputs (s, yyf)
  33. # define yyWriteNl (void) fputc ('\n', yyf)
  34.  
  35. # line 79 "Shapes.puma"
  36.  
  37. # include "Tree.h"
  38. # include "Idents.h"
  39. # include "StringMe.h"
  40. # include "Definiti.h"
  41.  
  42. # include "Types.h"  /* ArrayFormals */
  43.  
  44.  
  45.  
  46. static FILE * yyf = stdout;
  47.  
  48. static void yyAbort
  49. # ifdef __cplusplus
  50.  (char * yyFunction)
  51. # else
  52.  (yyFunction) char * yyFunction;
  53. # endif
  54. {
  55.  (void) fprintf (stderr, "Error: module Shapes, routine %s failed\n", yyFunction);
  56.  exit (1);
  57. }
  58.  
  59. void SetCurrentShape ARGS((tTree t));
  60. static void SetCurrentShapeList ARGS((tTree formals, tTree actuals));
  61. void DelCurrentShape ARGS((tTree t));
  62. static void DelCurrentShapeList ARGS((tTree formals));
  63. void SetAllocateShapes ARGS((tTree t));
  64. void ResetDeallocateShapes ARGS((tTree t));
  65. void GetCurrentShape ARGS((tTree t, shape s));
  66. static void GetCurrentShapeObj ARGS((tDefinitions t, shape s));
  67. static void GetCurrentShapeList ARGS((tTree t, shape s, int n));
  68. void PrintCurrentShape ARGS((shape s));
  69. tTree MakeFullShape ARGS((tTree t));
  70. static void MakeFullIndexShape ARGS((tTree t, shape s, int n));
  71. bool IsWholeVar ARGS((tTree t));
  72. static bool FullIndexSlices ARGS((tTree t, shape s, int n));
  73. static bool FullIndexSlice ARGS((tTree t, shape s, int n));
  74. static void PrintCompare ARGS((tTree e1, tTree e2, bool is));
  75. tTree NormalizeShape ARGS((tTree t));
  76. bool IsContiguousSection ARGS((tTree t));
  77. static bool IsContiguousShape ARGS((tTree t, shape s, int n));
  78. static bool SingleIndexes ARGS((tTree indexes));
  79.  
  80. void SetCurrentShape
  81. # if defined __STDC__ | defined __cplusplus
  82. (register tTree t)
  83. # else
  84. (t)
  85.  register tTree t;
  86. # endif
  87. {
  88.   if (t == NoTree) return;
  89.   if (t->Kind == kINDEXED_VAR) {
  90.   if (t->INDEXED_VAR.IND_VAR->Kind == kUSED_VAR) {
  91. # line 97 "Shapes.puma"
  92.   {
  93. # line 98 "Shapes.puma"
  94.    SetCurrentShapeList (ArrayFormals (t->INDEXED_VAR.IND_VAR->USED_VAR.VARNAME->VAR_OBJ.Object), t->INDEXED_VAR.IND_EXPS);
  95.   }
  96.    return;
  97.  
  98.   }
  99.   }
  100. # line 101 "Shapes.puma"
  101.   {
  102. # line 102 "Shapes.puma"
  103.    printf ("SetCurrentShape fails\n");
  104. # line 103 "Shapes.puma"
  105.    FileUnparse (stdout, t);
  106. # line 104 "Shapes.puma"
  107.    WriteTree (stdout, t);
  108. # line 105 "Shapes.puma"
  109.    exit (- 1);
  110.   }
  111.    return;
  112.  
  113. ;
  114. }
  115.  
  116. static void SetCurrentShapeList
  117. # if defined __STDC__ | defined __cplusplus
  118. (register tTree formals, register tTree actuals)
  119. # else
  120. (formals, actuals)
  121.  register tTree formals;
  122.  register tTree actuals;
  123. # endif
  124. {
  125.   if (formals == NoTree) return;
  126.   if (actuals == NoTree) return;
  127.   if (formals->Kind == kTYPE_LIST) {
  128.   if (actuals->Kind == kBTE_LIST) {
  129. # line 110 "Shapes.puma"
  130.   {
  131. # line 111 "Shapes.puma"
  132.    SetCurrentShapeList (formals->TYPE_LIST.Elem, actuals->BTE_LIST.Elem);
  133. # line 112 "Shapes.puma"
  134.    SetCurrentShapeList (formals->TYPE_LIST.Next, actuals->BTE_LIST.Next);
  135.   }
  136.    return;
  137.  
  138.   }
  139.   }
  140.   if (formals->Kind == kDYNAMIC) {
  141. # line 115 "Shapes.puma"
  142.   {
  143. # line 116 "Shapes.puma"
  144.  if (formals->DYNAMIC.Shape != NoTree)
  145.         printf ("Warning: Shape has been reset for one dimension\n");
  146.  
  147. # line 119 "Shapes.puma"
  148.    formals->DYNAMIC.Shape = actuals;
  149.   }
  150.    return;
  151.  
  152.   }
  153.   if (formals->Kind == kTYPE_EMPTY) {
  154.   if (actuals->Kind == kBTE_EMPTY) {
  155. # line 122 "Shapes.puma"
  156.    return;
  157.  
  158.   }
  159. # line 130 "Shapes.puma"
  160.   {
  161. # line 131 "Shapes.puma"
  162.    printf ("SetCurrentShapeList: more actuals than formals\n");
  163. # line 132 "Shapes.puma"
  164.    exit (- 1);
  165.   }
  166.    return;
  167.  
  168.   }
  169.   if (actuals->Kind == kBTE_EMPTY) {
  170. # line 125 "Shapes.puma"
  171.   {
  172. # line 126 "Shapes.puma"
  173.    printf ("SetCurrentShapeList: more formals than actuals\n");
  174. # line 127 "Shapes.puma"
  175.    exit (- 1);
  176.   }
  177.    return;
  178.  
  179.   }
  180. # line 135 "Shapes.puma"
  181.   {
  182. # line 136 "Shapes.puma"
  183.    printf ("SetCurrentShapeList fails\n");
  184. # line 137 "Shapes.puma"
  185.    printf ("formals : ");
  186. # line 137 "Shapes.puma"
  187.    FileUnparse (stdout, formals);
  188. # line 137 "Shapes.puma"
  189.    printf ("\n");
  190. # line 138 "Shapes.puma"
  191.    printf ("actuals : ");
  192. # line 138 "Shapes.puma"
  193.    FileUnparse (stdout, actuals);
  194. # line 138 "Shapes.puma"
  195.    printf ("\n");
  196. # line 139 "Shapes.puma"
  197.    WriteTree (stdout, formals);
  198. # line 140 "Shapes.puma"
  199.    WriteTree (stdout, actuals);
  200. # line 141 "Shapes.puma"
  201.    error_protocol ("something is wrong with SetCurrentShapeList");
  202. # line 142 "Shapes.puma"
  203.    kill_in_protocol ();
  204.   }
  205.    return;
  206.  
  207. ;
  208. }
  209.  
  210. void DelCurrentShape
  211. # if defined __STDC__ | defined __cplusplus
  212. (register tTree t)
  213. # else
  214. (t)
  215.  register tTree t;
  216. # endif
  217. {
  218.   if (t == NoTree) return;
  219.   if (t->Kind == kUSED_VAR) {
  220. # line 153 "Shapes.puma"
  221.   {
  222. # line 154 "Shapes.puma"
  223.    DelCurrentShapeList (ArrayFormals (t->USED_VAR.VARNAME->VAR_OBJ.Object));
  224.   }
  225.    return;
  226.  
  227.   }
  228. # line 157 "Shapes.puma"
  229.   {
  230. # line 158 "Shapes.puma"
  231.    printf ("DelCurrentShape fails\n");
  232. # line 159 "Shapes.puma"
  233.    FileUnparse (stdout, t);
  234. # line 160 "Shapes.puma"
  235.    WriteTree (stdout, t);
  236. # line 161 "Shapes.puma"
  237.    exit (- 1);
  238.   }
  239.    return;
  240.  
  241. ;
  242. }
  243.  
  244. static void DelCurrentShapeList
  245. # if defined __STDC__ | defined __cplusplus
  246. (register tTree formals)
  247. # else
  248. (formals)
  249.  register tTree formals;
  250. # endif
  251. {
  252.   if (formals == NoTree) return;
  253.   if (formals->Kind == kTYPE_LIST) {
  254. # line 166 "Shapes.puma"
  255.   {
  256. # line 167 "Shapes.puma"
  257.    DelCurrentShapeList (formals->TYPE_LIST.Elem);
  258. # line 168 "Shapes.puma"
  259.    DelCurrentShapeList (formals->TYPE_LIST.Next);
  260.   }
  261.    return;
  262.  
  263.   }
  264.   if (formals->Kind == kDYNAMIC) {
  265. # line 171 "Shapes.puma"
  266.   {
  267. # line 172 "Shapes.puma"
  268.  if (formals->DYNAMIC.Shape == NoTree)
  269.         printf ("Warning: Shape in one dimension was already deleted\n");
  270.  
  271. # line 175 "Shapes.puma"
  272.    formals->DYNAMIC.Shape = NoTree;
  273.   }
  274.    return;
  275.  
  276.   }
  277. ;
  278. }
  279.  
  280. void SetAllocateShapes
  281. # if defined __STDC__ | defined __cplusplus
  282. (register tTree t)
  283. # else
  284. (t)
  285.  register tTree t;
  286. # endif
  287. {
  288.   if (t == NoTree) return;
  289.   if (t->Kind == kBTP_LIST) {
  290.   if (t->BTP_LIST.Elem->Kind == kVAR_PARAM) {
  291. # line 186 "Shapes.puma"
  292.   {
  293. # line 187 "Shapes.puma"
  294.    SetCurrentShape (t->BTP_LIST.Elem->VAR_PARAM.V);
  295. # line 188 "Shapes.puma"
  296.    SetAllocateShapes (t->BTP_LIST.Next);
  297.   }
  298.    return;
  299.  
  300.   }
  301.   }
  302. ;
  303. }
  304.  
  305. void ResetDeallocateShapes
  306. # if defined __STDC__ | defined __cplusplus
  307. (register tTree t)
  308. # else
  309. (t)
  310.  register tTree t;
  311. # endif
  312. {
  313.   if (t == NoTree) return;
  314.   if (t->Kind == kBTP_LIST) {
  315.   if (t->BTP_LIST.Elem->Kind == kVAR_PARAM) {
  316. # line 199 "Shapes.puma"
  317.   {
  318. # line 200 "Shapes.puma"
  319.    DelCurrentShape (t->BTP_LIST.Elem->VAR_PARAM.V);
  320. # line 201 "Shapes.puma"
  321.    ResetDeallocateShapes (t->BTP_LIST.Next);
  322.   }
  323.    return;
  324.  
  325.   }
  326.   }
  327. ;
  328. }
  329.  
  330. void GetCurrentShape
  331. # if defined __STDC__ | defined __cplusplus
  332. (register tTree t, shape s)
  333. # else
  334. (t, s)
  335.  register tTree t;
  336.  shape s;
  337. # endif
  338. {
  339.   if (t == NoTree) return;
  340.   if (t->Kind == kINDEXED_VAR) {
  341. # line 212 "Shapes.puma"
  342.   {
  343. # line 213 "Shapes.puma"
  344.    GetCurrentShape (t->INDEXED_VAR.IND_VAR, s);
  345.   }
  346.    return;
  347.  
  348.   }
  349.   if (t->Kind == kUSED_VAR) {
  350. # line 216 "Shapes.puma"
  351.   {
  352. # line 217 "Shapes.puma"
  353.    GetCurrentShape (t->USED_VAR.VARNAME, s);
  354.   }
  355.    return;
  356.  
  357.   }
  358.   if (t->Kind == kVAR_OBJ) {
  359. # line 220 "Shapes.puma"
  360.   {
  361. # line 221 "Shapes.puma"
  362.    GetCurrentShapeObj (t->VAR_OBJ.Object, s);
  363.   }
  364.    return;
  365.  
  366.   }
  367. ;
  368. }
  369.  
  370. static void GetCurrentShapeObj
  371. # if defined __STDC__ | defined __cplusplus
  372. (register tDefinitions t, shape s)
  373. # else
  374. (t, s)
  375.  register tDefinitions t;
  376.  shape s;
  377. # endif
  378. {
  379.   if (t == NoDefinitions) return;
  380.   if (t->Kind == kVarObject) {
  381.   if (t->VarObject.decl->Kind == kVAR_DECL) {
  382.   if (t->VarObject.decl->VAR_DECL.VAL->Kind == kARRAY_TYPE) {
  383. # line 226 "Shapes.puma"
  384.   {
  385. # line 227 "Shapes.puma"
  386.    GetCurrentShapeList (t->VarObject.decl->VAR_DECL.VAL->ARRAY_TYPE.ARRAY_INDEX_TYPES, s, 1);
  387.   }
  388.    return;
  389.  
  390.   }
  391.   }
  392.   if (t->VarObject.decl->Kind == kVAR_PARAM_DECL) {
  393.   if (t->VarObject.decl->VAR_PARAM_DECL.VAL->Kind == kARRAY_TYPE) {
  394. # line 230 "Shapes.puma"
  395.   {
  396. # line 231 "Shapes.puma"
  397.    GetCurrentShapeList (t->VarObject.decl->VAR_PARAM_DECL.VAL->ARRAY_TYPE.ARRAY_INDEX_TYPES, s, 1);
  398.   }
  399.    return;
  400.  
  401.   }
  402.   }
  403.   }
  404. # line 234 "Shapes.puma"
  405.   {
  406. # line 235 "Shapes.puma"
  407.  s->rank = 0;
  408.   }
  409.    return;
  410.  
  411. ;
  412. }
  413.  
  414. static void GetCurrentShapeList
  415. # if defined __STDC__ | defined __cplusplus
  416. (register tTree t, shape s, register int n)
  417. # else
  418. (t, s, n)
  419.  register tTree t;
  420.  shape s;
  421.  register int n;
  422. # endif
  423. {
  424.   if (t == NoTree) return;
  425.   if (t->Kind == kTYPE_LIST) {
  426.   if (t->TYPE_LIST.Elem->Kind == kDYNAMIC) {
  427. # line 240 "Shapes.puma"
  428.   {
  429. # line 241 "Shapes.puma"
  430.  if (t->TYPE_LIST.Elem->DYNAMIC.Shape == NoTree)
  431.          { printf ("Shape of dynamic array unknown\n");
  432.            printf ("Seems to be use for allocate\n");
  433.            exit (-1);
  434.          }
  435.  
  436. # line 247 "Shapes.puma"
  437.    GetCurrentShapeList (t->TYPE_LIST.Elem, s, n);
  438. # line 248 "Shapes.puma"
  439.    GetCurrentShapeList (t->TYPE_LIST.Next, s, n + 1);
  440.   }
  441.    return;
  442.  
  443.   }
  444.   if (t->TYPE_LIST.Elem->Kind == kINDEX_TYPE) {
  445. # line 251 "Shapes.puma"
  446.   {
  447. # line 252 "Shapes.puma"
  448.    GetCurrentShapeList (t->TYPE_LIST.Elem, s, n);
  449. # line 253 "Shapes.puma"
  450.    GetCurrentShapeList (t->TYPE_LIST.Next, s, n + 1);
  451.   }
  452.    return;
  453.  
  454.   }
  455.   }
  456.   if (t->Kind == kTYPE_EMPTY) {
  457. # line 256 "Shapes.puma"
  458.    return;
  459.  
  460.   }
  461.   if (t->Kind == kDYNAMIC) {
  462.   if (t->DYNAMIC.Shape->Kind == kSLICE_EXP) {
  463. # line 259 "Shapes.puma"
  464.   {
  465. # line 260 "Shapes.puma"
  466.  s->rank = n;
  467.       s->bounds[n-1][0] = t->DYNAMIC.Shape->SLICE_EXP.START;
  468.       s->bounds[n-1][1] = t->DYNAMIC.Shape->SLICE_EXP.STOP;
  469.       s->bounds[n-1][2] = NoTree;
  470.  
  471.   }
  472.    return;
  473.  
  474.   }
  475. # line 275 "Shapes.puma"
  476.   {
  477. # line 276 "Shapes.puma"
  478.    printf ("dynamic shape not normaliyed\n");
  479. # line 277 "Shapes.puma"
  480.    WriteTree (stdout, t);
  481. # line 278 "Shapes.puma"
  482.    kill_in_protocol ();
  483.   }
  484.    return;
  485.  
  486.   }
  487.   if (t->Kind == kINDEX_TYPE) {
  488. # line 267 "Shapes.puma"
  489.   {
  490. # line 268 "Shapes.puma"
  491.  s->rank = n;
  492.       s->bounds[n-1][0] = t->INDEX_TYPE.LOWER;
  493.       s->bounds[n-1][1] = t->INDEX_TYPE.UPPER;
  494.       s->bounds[n-1][2] = NoTree;
  495.  
  496.   }
  497.    return;
  498.  
  499.   }
  500. ;
  501. }
  502.  
  503. void PrintCurrentShape
  504. # if defined __STDC__ | defined __cplusplus
  505. (shape s)
  506. # else
  507. (s)
  508.  shape s;
  509. # endif
  510. {
  511. # line 283 "Shapes.puma"
  512.  
  513. int i;
  514.  
  515. # line 287 "Shapes.puma"
  516.   {
  517. # line 288 "Shapes.puma"
  518.  printf ("Shape is : \n");
  519.     for (i=0;i<s->rank;i++)
  520.      { FileUnparse (stdout, s->bounds[i][0]);
  521.        printf (" - ");
  522.        FileUnparse (stdout, s->bounds[i][1]);
  523.        if (s->bounds[i][2] != NoTree)
  524.          { printf (" step ");
  525.            FileUnparse (stdout, s->bounds[i][2]);
  526.          }
  527.        printf ("\n");
  528.      }
  529.  
  530.   }
  531.    return;
  532.  
  533. ;
  534. }
  535.  
  536. tTree MakeFullShape
  537. # if defined __STDC__ | defined __cplusplus
  538. (register tTree t)
  539. # else
  540. (t)
  541.  register tTree t;
  542. # endif
  543. {
  544. # line 316 "Shapes.puma"
  545.  
  546. struct_shape shp;
  547. int i;
  548. tTree ind, newvar, inc;
  549.  
  550.   if (t->Kind == kUSED_VAR) {
  551. # line 322 "Shapes.puma"
  552.   {
  553. # line 323 "Shapes.puma"
  554.    if (! (VarRank (t->USED_VAR.VARNAME->VAR_OBJ.Object) == 0)) goto yyL1;
  555.   }
  556.    return t;
  557. yyL1:;
  558.  
  559. # line 327 "Shapes.puma"
  560.   {
  561. # line 328 "Shapes.puma"
  562.  GetCurrentShape (t, &shp);
  563.      ind = mBTE_EMPTY ();
  564.      for (i=shp.rank; i>0; i--)
  565.        { inc = shp.bounds[i-1][2];
  566.          if (inc == NoTree) inc = mDUMMY_EXP();
  567.          ind = mBTE_LIST (mSLICE_EXP (shp.bounds[i-1][0],
  568.                  shp.bounds[i-1][1], inc), ind);
  569.        }
  570.      newvar = mINDEXED_VAR (t, ind);
  571.  
  572.   }
  573.    return newvar;
  574.  
  575.   }
  576.   if (t->Kind == kINDEXED_VAR) {
  577.   if (t->INDEXED_VAR.IND_VAR->Kind == kUSED_VAR) {
  578. # line 341 "Shapes.puma"
  579.   {
  580. # line 342 "Shapes.puma"
  581.  
  582.      GetCurrentShape (t, &shp);
  583.      MakeFullIndexShape (t->INDEXED_VAR.IND_EXPS, &shp, 0);
  584.  
  585.   }
  586.    return t;
  587.  
  588.   }
  589.   }
  590. # line 349 "Shapes.puma"
  591.   {
  592. # line 350 "Shapes.puma"
  593.    printf ("MakeFullShape failed\n");
  594. # line 351 "Shapes.puma"
  595.    FileUnparse (stdout, t);
  596. # line 352 "Shapes.puma"
  597.    WriteTree (stdout, t);
  598. # line 353 "Shapes.puma"
  599.    kill_in_protocol ();
  600.   }
  601.    return t;
  602.  
  603. }
  604.  
  605. static void MakeFullIndexShape
  606. # if defined __STDC__ | defined __cplusplus
  607. (register tTree t, shape s, register int n)
  608. # else
  609. (t, s, n)
  610.  register tTree t;
  611.  shape s;
  612.  register int n;
  613. # endif
  614. {
  615.   if (t == NoTree) return;
  616.   if (t->Kind == kBTE_LIST) {
  617.   if (t->BTE_LIST.Elem->Kind == kSLICE_EXP) {
  618. # line 359 "Shapes.puma"
  619.   {
  620. # line 360 "Shapes.puma"
  621.  if (t->BTE_LIST.Elem->SLICE_EXP.START->Kind == kDUMMY_EXP)
  622.         t->BTE_LIST.Elem->SLICE_EXP.START = s->bounds[n][0];
  623.      if (t->BTE_LIST.Elem->SLICE_EXP.STOP->Kind == kDUMMY_EXP)
  624.         t->BTE_LIST.Elem->SLICE_EXP.STOP = s->bounds[n][1];
  625.  
  626. # line 365 "Shapes.puma"
  627.    MakeFullIndexShape (t->BTE_LIST.Next, s, n + 1);
  628.   }
  629.    return;
  630.  
  631.   }
  632. # line 368 "Shapes.puma"
  633.   {
  634. # line 370 "Shapes.puma"
  635.    MakeFullIndexShape (t->BTE_LIST.Next, s, n + 1);
  636.   }
  637.    return;
  638.  
  639.   }
  640.   if (t->Kind == kBTE_EMPTY) {
  641. # line 373 "Shapes.puma"
  642.    return;
  643.  
  644.   }
  645. ;
  646. }
  647.  
  648. bool IsWholeVar
  649. # if defined __STDC__ | defined __cplusplus
  650. (register tTree t)
  651. # else
  652. (t)
  653.  register tTree t;
  654. # endif
  655. {
  656. # line 393 "Shapes.puma"
  657.  
  658. struct_shape shp;
  659. bool is;
  660.  
  661.   if (t->Kind == kUSED_VAR) {
  662. # line 398 "Shapes.puma"
  663.    return true;
  664.  
  665.   }
  666.   if (t->Kind == kINDEXED_VAR) {
  667.   if (t->INDEXED_VAR.IND_VAR->Kind == kUSED_VAR) {
  668. # line 402 "Shapes.puma"
  669.   {
  670. # line 403 "Shapes.puma"
  671.  GetCurrentShape (t, &shp);
  672.      is = FullIndexSlices (t->INDEXED_VAR.IND_EXPS, &shp, 0);
  673.  
  674.   }
  675.    return is;
  676.  
  677.   }
  678.   }
  679. # line 409 "Shapes.puma"
  680.   {
  681. # line 410 "Shapes.puma"
  682.    failure_protocol ("Shapes", "IsWholeVar", t);
  683.   }
  684.    return false;
  685.  
  686. }
  687.  
  688. static bool FullIndexSlices
  689. # if defined __STDC__ | defined __cplusplus
  690. (register tTree t, shape s, register int n)
  691. # else
  692. (t, s, n)
  693.  register tTree t;
  694.  shape s;
  695.  register int n;
  696. # endif
  697. {
  698. # line 416 "Shapes.puma"
  699.  
  700. bool is;
  701. int val;
  702.  
  703.   if (t == NoTree) return false;
  704.   if (t->Kind == kBTE_LIST) {
  705.   if (t->BTE_LIST.Elem->Kind == kSLICE_EXP) {
  706. # line 421 "Shapes.puma"
  707.   {
  708. # line 425 "Shapes.puma"
  709.    if (! (FullIndexSlice (t->BTE_LIST.Elem, s, n))) goto yyL1;
  710.   {
  711. # line 426 "Shapes.puma"
  712.    if (! (FullIndexSlices (t->BTE_LIST.Next, s, n + 1))) goto yyL1;
  713.   }
  714.   }
  715.    return true;
  716. yyL1:;
  717.  
  718.   }
  719.   }
  720.   if (t->Kind == kBTE_EMPTY) {
  721. # line 429 "Shapes.puma"
  722.    return true;
  723.  
  724.   }
  725.   return false;
  726. }
  727.  
  728. static bool FullIndexSlice
  729. # if defined __STDC__ | defined __cplusplus
  730. (register tTree t, shape s, register int n)
  731. # else
  732. (t, s, n)
  733.  register tTree t;
  734.  shape s;
  735.  register int n;
  736. # endif
  737. {
  738. # line 434 "Shapes.puma"
  739.  
  740. bool is;
  741. int val;
  742.  
  743.   if (t == NoTree) return false;
  744.   if (t->Kind == kSLICE_EXP) {
  745. # line 439 "Shapes.puma"
  746.   {
  747. # line 443 "Shapes.puma"
  748.  is = true;
  749.  
  750.      if (t->SLICE_EXP.START->Kind != kDUMMY_EXP)
  751.         is = EqualExpression (t->SLICE_EXP.START, s->bounds[n][0]);
  752.  
  753.      if (is  && (t->SLICE_EXP.STOP->Kind != kDUMMY_EXP) )
  754.         is = EqualExpression (t->SLICE_EXP.STOP, s->bounds[n][1]);
  755.      if (is)
  756.         { SliceIncrement (t, &is, &val);
  757.           if (is) is = (val == 1);
  758.         }
  759.  
  760. # line 456 "Shapes.puma"
  761.    if (! (is == true)) goto yyL1;
  762.   }
  763.    return true;
  764. yyL1:;
  765.  
  766.   }
  767.   return false;
  768. }
  769.  
  770. static void PrintCompare
  771. # if defined __STDC__ | defined __cplusplus
  772. (register tTree e1, register tTree e2, register bool is)
  773. # else
  774. (e1, e2, is)
  775.  register tTree e1;
  776.  register tTree e2;
  777.  register bool is;
  778. # endif
  779. {
  780.   if (e1 == NoTree) return;
  781.   if (e2 == NoTree) return;
  782. # line 461 "Shapes.puma"
  783.   {
  784. # line 462 "Shapes.puma"
  785.    printf ("Compare, e1 = ");
  786. # line 462 "Shapes.puma"
  787.    FileUnparse (stdout, e1);
  788. # line 463 "Shapes.puma"
  789.    printf (" e2 = ");
  790. # line 463 "Shapes.puma"
  791.    FileUnparse (stdout, e2);
  792. # line 464 "Shapes.puma"
  793.  if (is) printf (" are equal\n");
  794.         else
  795.              printf (" not equal\n");
  796.   }
  797.    return;
  798.  
  799. ;
  800. }
  801.  
  802. tTree NormalizeShape
  803. # if defined __STDC__ | defined __cplusplus
  804. (register tTree t)
  805. # else
  806. (t)
  807.  register tTree t;
  808. # endif
  809. {
  810. # line 480 "Shapes.puma"
  811.  
  812. tTree newvar;
  813.  
  814.   if (t->Kind == kUSED_VAR) {
  815. # line 484 "Shapes.puma"
  816.    return t;
  817.  
  818.   }
  819.   if (t->Kind == kINDEXED_VAR) {
  820. # line 488 "Shapes.puma"
  821.   {
  822. # line 489 "Shapes.puma"
  823.  if (IsWholeVar(t))
  824.        newvar = t->INDEXED_VAR.IND_VAR;
  825.       else
  826.        newvar = MakeFullShape (t);
  827.  
  828.   }
  829.    return newvar;
  830.  
  831.   }
  832.   if (t->Kind == kVAR_EXP) {
  833. # line 497 "Shapes.puma"
  834.   {
  835. # line 498 "Shapes.puma"
  836.  t->VAR_EXP.V = NormalizeShape (t->VAR_EXP.V);
  837.   }
  838.    return t;
  839.  
  840.   }
  841. # line 502 "Shapes.puma"
  842.    return t;
  843.  
  844. }
  845.  
  846. bool IsContiguousSection
  847. # if defined __STDC__ | defined __cplusplus
  848. (register tTree t)
  849. # else
  850. (t)
  851.  register tTree t;
  852. # endif
  853. {
  854. # line 522 "Shapes.puma"
  855.  
  856. struct_shape s;
  857.  
  858.   if (t == NoTree) return false;
  859.   if (t->Kind == kUSED_VAR) {
  860. # line 526 "Shapes.puma"
  861.    return true;
  862.  
  863.   }
  864.   if (t->Kind == kINDEXED_VAR) {
  865.   if (t->INDEXED_VAR.IND_VAR->Kind == kUSED_VAR) {
  866. # line 529 "Shapes.puma"
  867.   {
  868. # line 531 "Shapes.puma"
  869.  GetCurrentShape (t, &s);
  870. # line 532 "Shapes.puma"
  871.    if (! (IsContiguousShape (t->INDEXED_VAR.IND_EXPS, & s, 0))) goto yyL2;
  872.   }
  873.    return true;
  874. yyL2:;
  875.  
  876.   }
  877.   }
  878.   return false;
  879. }
  880.  
  881. static bool IsContiguousShape
  882. # if defined __STDC__ | defined __cplusplus
  883. (register tTree t, shape s, register int n)
  884. # else
  885. (t, s, n)
  886.  register tTree t;
  887.  shape s;
  888.  register int n;
  889. # endif
  890. {
  891. # line 537 "Shapes.puma"
  892.  
  893. bool is;
  894. int val;
  895.  
  896.   if (t == NoTree) return false;
  897.   if (t->Kind == kBTE_EMPTY) {
  898. # line 542 "Shapes.puma"
  899.    return true;
  900.  
  901.   }
  902.   if (t->Kind == kBTE_LIST) {
  903.   if (t->BTE_LIST.Elem->Kind == kSLICE_EXP) {
  904. # line 545 "Shapes.puma"
  905.   {
  906. # line 547 "Shapes.puma"
  907.    if (! (FullIndexSlice (t->BTE_LIST.Elem, s, n))) goto yyL2;
  908.   {
  909. # line 548 "Shapes.puma"
  910.    if (! (IsContiguousShape (t->BTE_LIST.Next, s, n + 1))) goto yyL2;
  911.   }
  912.   }
  913.    return true;
  914. yyL2:;
  915.  
  916. # line 551 "Shapes.puma"
  917.   {
  918. # line 553 "Shapes.puma"
  919.    if (! (SingleIndexes (t->BTE_LIST.Next))) goto yyL3;
  920.   {
  921. # line 554 "Shapes.puma"
  922.  SliceIncrement (t->BTE_LIST.Elem, &is, &val);
  923. # line 555 "Shapes.puma"
  924.    if (! (is)) goto yyL3;
  925.   {
  926. # line 556 "Shapes.puma"
  927.    if (! (val == 1)) goto yyL3;
  928.   }
  929.   }
  930.   }
  931.    return true;
  932. yyL3:;
  933.  
  934.   }
  935. # line 559 "Shapes.puma"
  936.   {
  937. # line 560 "Shapes.puma"
  938.    if (! (SingleIndexes (t->BTE_LIST.Next))) goto yyL4;
  939.   }
  940.    return true;
  941. yyL4:;
  942.  
  943.   }
  944.   return false;
  945. }
  946.  
  947. static bool SingleIndexes
  948. # if defined __STDC__ | defined __cplusplus
  949. (register tTree indexes)
  950. # else
  951. (indexes)
  952.  register tTree indexes;
  953. # endif
  954. {
  955.   if (indexes == NoTree) return false;
  956.   if (indexes->Kind == kBTE_EMPTY) {
  957. # line 565 "Shapes.puma"
  958.    return true;
  959.  
  960.   }
  961.   if (indexes->Kind == kBTE_LIST) {
  962.   if (indexes->BTE_LIST.Elem->Kind == kSLICE_EXP) {
  963. # line 568 "Shapes.puma"
  964.   {
  965. # line 569 "Shapes.puma"
  966.    return false;
  967.   }
  968.  
  969.   }
  970. # line 572 "Shapes.puma"
  971.    return true;
  972.  
  973.   }
  974.   return false;
  975. }
  976.  
  977. void BeginShapes ()
  978. {
  979. }
  980.  
  981. void CloseShapes ()
  982. {
  983. }
  984.